Search code examples
javascriptjquerybootstrap-studio

Page-specific script in Bootstrap Studio


(This problem is specific to Bootstrap Studio)

I need to include a piece of JS that is specific to just one page.

  • I can’t put it in a JS file since it is specific to one page and BSS apparently has no option to link JS files to individual pages. It always imports all JS files in all pages (which itself is a serious limitation in my opinion).
  • I can’t put it in a Custom Code block in the page because it uses jQuery, which is loaded AFTER the entire page content (including jQuery.js) by BSS, thus I see $ is not defined error when my script runs.

What is my way out?


Solution

  • You can easily right-click on the js file. In the dropdown you can select "Visibility" and then select all the html pages where you want to use your js file.