ExamGecko
Question list
Search
Search

Question 45 - AD0-E711 discussion

Report
Export

A JavaScript library, made by a front-end developer, needs to be connected to a single custom page.

A method (rom this library must also be called to initialize it. The decision is made to add this JavaScript snippet directly to the PHTML page template.

Which function should be used to complete this task?

A.
Use the "require" function. because it is used to run the code immediately.
Answers
A.
Use the "require" function. because it is used to run the code immediately.
B.
Use a Text/x-magento-init" script block, and then put the initialization JavaScript snippet into It.
Answers
B.
Use a Text/x-magento-init" script block, and then put the initialization JavaScript snippet into It.
C.
Use the "define" function, because it is used to define modules for further usage.
Answers
C.
Use the "define" function, because it is used to define modules for further usage.
Suggested answer: B

Explanation:

To add a JavaScript snippet directly to the PHTML page template, you should use a "text/x-magentoinit" script block and put the initialization JavaScript snippet into it. This approach allows you to initialize JavaScript components properly in Magento. Reference:

https://devdocs.magento.com/guides/v2.4/javascript-dev-guide/javascript/js_init.html

asked 02/10/2024
Camille Rudio
35 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first