![]() When you first learn HTML, you’re told script tags live in the tag: Title. If the script takes a little longer to load than expected, for example if the network is a bit slow or if you’re on a mobile device and the connection is a bit sloppy, the visitor will likely see a blank page until the script is loaded and executed. Once this process is done, the parsing can resume, and the rest of the HTML can be analyzed.Īs you can imagine, this operation can have a huge impact on the loading time of the page. ![]() Whenever the HTML parser finds this line, a request will be made to fetch the script, and the script is executed. When loading a script on an HTML page, you need to be careful not to harm the loading performance of the page.Ī script is traditionally included in the page in this way: Depending on where and how you add your scripts to an HTML page will influence the loading time They allow you to write extremely flexible code which means you can spend more time writing the HTML for your project and less time worrying about writing a custom event listener for each new element you add.When loading a script on an HTML page, you need to be careful not to harm the loading performance of the page. Conclusionĭata attributes in JavaScript are incredibly useful. This means that if we add a new button that references a new modal we won't need to write any additional JavaScript. This code is also flexible since it will get any element with the custom data-modal-id attribute. ![]() Inside this event listener we are using the modal id to get the modal link to that button and adding the show class so it is now visible. We are then looping through them and adding a click event listener to each one. In the above code we are selecting all elements that contain our custom data-modal-id attribute. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |