frontend-developer-1
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Customize and Create JavaScript<br />
What are the advantages and disadvantages of inline JavaScript?<br />
The advantage is that inline JavaScript is easy to include, and it does not send an<br />
additional request. The downside, though, is that the code becomes difficult to<br />
reuse. Additionally, depending on what type of Javascript is rendered, this code is<br />
not deferred and can block page loading.<br />
If other places in the application need the same functionality, the script must be<br />
included there as well. This inhibits caching because the JavaScript cannot be<br />
cached separately from the main document and must be sent again every time.<br />
Also, as the complexity of the logic increases, it begins to be difficult to manage. At<br />
that point (or if you begin development knowing that it will soon get to this point),<br />
splitting your JavaScript into multiple files will ease development.<br />
Additionally, inline JavaScript cannot be controlled with a Content-Security-Policy.<br />
This means that inline JavaScript is more likely to be exploited through Cross-Site-<br />
Scripting (XSS).<br />
HELPFUL LINKS:<br />
• https://<strong>developer</strong>.chrome.com/extensions/contentSecurityPolicy<br />
How can JavaScript be loaded asynchronously on a page?<br />
This occurs through placing functionality into require or define methods. What<br />
is the difference between these two methods? require executes immediately.<br />
When RequireJS is loading modules, and it comes across one that has this method,<br />
the contents are executed. define wraps a module that can be requested and<br />
used by other modules. As a result, it is only executed when called, such as<br />
Copyright © 2018, SwiftOtter, Inc.<br />
65