![]() If you always use jQuery, you’ll easily ignore things like the nuances of browser support, performance optimization, and how to write good, readable code in general. I’ve always tried to avoid using jQuery or, really, any helper library because I think it’s important to understand how the underlying JavaScript engine in the browser works. However, native JavaScript is spectacularly useful, too, even if you might have type in some extra characters compared to jQuery’s helper methods. There’s a reason it’s the most popular JavaScript library on the web. JQuery is a great tool in web development. Load it asynchronously, and use tag sequencing to ensure the dependency has loaded before it is used by the main tag. If you must load jQuery, use a recent, minified version of the library. If you only need to do simple DOM traversal or trivial HTTP requests, look into using native JavaScript rather than loading the library. If the site is not running jQuery, look at the complexity of the tasks you want to do. Just make sure to avoid race conditions if jQuery is loaded asynchronously (as it should). If the site already loads the jQuery library, use it at will. Here are my own, personal rules of thumb: How to write an HTTP POST request with and without jQuery Once you’ve created that Custom HTML tag, scroll down to its Advanced settings, and set its Tag firing options to Once per page. It’s not perfect, since sometimes just because the library loaded doesn’t mean it managed to execute correctly (if there are conflicts in the page’s global namespace, for example), and an error isn’t always thrown if the library fails to load. ![]() Because it’s asynchronous, you also add a load listener, which fires when the library has loaded successfully, and an error listener, which fires if the library failed to load due to an error. Do not add any triggers to this tag.īasically, you create an asynchronous load request for the jQuery library from jQuery’s own CDN (content distribution network). You’ll need to enable the Container ID and HTML ID built-in variables for this. ![]() Var el = document.createElement( 'script') Įl.addEventListener( 'load', function() ) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |