Here’s some relevant notes:
Both outer and canvas:
if ( bricks_is_builder() ) {
}
Only outer (this code won’t run in the inner canvas (your actual Page/template)):
if ( bricks_is_builder_main() ) {
}
There are some snippets that should be run on the Bricks canvas only, like adding outlines in the editor. Here’s the condition for this:
if ( bricks_is_builder() && ! bricks_is_builder_main() ) {
}
On the canvas (the inner frame) & frontend, not the builder panel (outer stuff):
if ( ! bricks_is_builder_main() ) {
}
Only frontend:
if ( bricks_is_frontend() ) {
}
or
if ( ! bricks_is_builder() && ! is_admin() ) {
}