user10260931
user10260931

Reputation:

Where is Bootstrap located in the DOM

Our website gets the Bootstrap from a CDN but this has caused issues with a few of our clients whose network security blocks the request. We've also had this happen with Syncfusion's CDN and as a temporary workaround we check for window.ejs and alert the user if it's not there. I'm having trouble finding anything related to Bootstrap in the DOM in order to implement the same fix.

Upvotes: 0

Views: 354

Answers (1)

crenshaw-dev
crenshaw-dev

Reputation: 8382

The DOM, or Document Object Model, is different from the window object on which you've found window.ejs. While the JavaScript API can be used to access the DOM, window is part of the browser's JavaScript API that provides access to many aspects of the users' experience.

I think you're trying to "feature detect" the presence of Bootstrap by inspecting the JavaScript API.

Location in the JavaScript API

If Bootstrap JS is loaded (Bootstrap can be loaded with only the CSS component), then its jQuery plugins will be available in JavaScript.

To detect whether Bootstrap has been loaded on a page, try something like var isBootstrapLoaded = typeof $().tooltip !== 'undefined'. This checks for the presence of the Bootstrap tooltip API.

Location in the DOM

To answer your question more literally by its title...

Bootstrap is included in a page using <script> and <link> tags for JavaScript and CSS, respectively. See the Bootstrap homepage for example markup.

These can be located anywhere in the page, but are usually found inside the <head> element.

Dealing with blocked network requests

One solution to blocked requests to Bootstrap is to self-host the files. The performance benefit of CDNs is waning with browsers' additions of cache privacy protections. Often self-hosting is actually beneficial for performance.

Upvotes: 2

Related Questions