1D0-735 practice question 7 of 15

Which of the following is not a best practice when using JavaScript libraries?

Full set: 55 questions
Answer options
A: Developers should ensure the library functions they use are cross-browser compatible for the version of HTML they are using.
B: Developers should link to the library file and to each plug in script in the section of the HTML document using the tag.
C: Developers should use plugins from a variety of JavaScript libraries to ensure compatibility. Correct answer
D: Developers should become familiar with one library then optimize HTML code with that specific library in mind.
Correct Answer:
C. Developers should use plugins from a variety of JavaScript libraries to ensure compatibility.
Explanation

Using plugins from a variety of different JavaScript libraries is not a best practice because it is highly likely to cause conflicts and performance issues, rather than ensure compatibility. Different libraries may attempt to use the same global variable names (e.g., the $ alias is common), leading to unpredictable behavior and bugs. Furthermore, loading multiple large libraries increases the overall page size and parsing time, negatively impacting user experience. A standard best practice is to select a primary library or framework for a project to maintain consistency, reduce overhead, and simplify dependency management.

Why Incorrect

A. Ensuring functions are cross-browser compatible is a core best practice in web development and a primary motivation for using a mature JavaScript library in the first place.
B. While modern performance best practices often recommend placing scripts before the closing tag, linking in the is a functional, albeit often suboptimal, approach.
D. Becoming proficient with one library and optimizing code for its ecosystem is an excellent practice that enhances developer productivity, code quality, and application performance. ---

References

1. Official Vendor Documentation (jQuery): The existence of a jQuery.noConflict() method in the official jQuery library documentation explicitly demonstrates that conflicts between libraries are a known problem that must be managed, directly contradicting the claim that mixing libraries ensures compatibility.

Source: jQuery Foundation, "jQuery.noConflict()", jQuery API Documentation. Retrieved from httpsa://api.jquery.com/jquery.noconflict/ (Section: "Description").

2. Official Vendor Documentation (Mozilla Developer Network): MDN documentation, a sanctioned resource for web standards, advises on script placement for performance, noting that scripts in the can be "parser-blocking." This supports the idea that the practice in option B is not always a "best" practice, but it does not make it fundamentally incorrect like option C.

Source: MDN Web Docs, "<script>: The Script element", Mozilla. Retrieved from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes (Section: "Notes").

3. Official Vendor Documentation (Google): Google's web development guidelines emphasize the performance cost of large JavaScript bundles, which is exacerbated by loading multiple, redundant libraries. This reinforces why the practice described in option C is detrimental.

Source: Houssein Djirdeh, "JavaScript Start-up Optimization", web.dev by Google, 2023. Retrieved from https://web.dev/articles/optimizing-javascript-startup (Section: "Evaluate your dependencies").

4. University Courseware (Stanford University): Web development courses frequently teach the importance of choosing a technology stack and sticking to it to avoid complexity and ensure maintainability, which aligns with the best practice described in option D and argues against the chaotic approach in option C.

Source: Stanford University, CS193X - Web Programming, Lecture Notes on JavaScript Frameworks. (General principle taught in such courses, e.g., focusing on the React ecosystem).

Scroll to Top