Magento Expert Forum - Improve your Magento experience

Results 1 to 2 of 2

Configure JavaScript resources in Magento 2

  1. #1
    [ Contributor ] Wajid Hussain's Avatar
    Join Date
    Nov 2014
    Posts
    206
    Thanks
    3
    Thanked 7 Times in 6 Posts

    Default Configure JavaScript resources in Magento 2

    JavaScript is an object oriented scripting language, and it is very useful for connected host environments like the web browser to the objects of its environment to provide programmatic control over them. In Magento 2, one of the major advantages of using JavaScript is making storefront dynamic and interactive, but including JavaScript in the page headers makes uploading of the pages slow down . The solution of this problem is to add the ability to use the RequireJS library in Magento 2.

    RequireJS is one of the best and popular frameworks for managing dependencies between modules and it improves the page load time as it allows JavaScript to load in the Magento 2 background. In this article, I’m going to show you how to configure JavaScript resources in your Magento 2 store.

    Configure JavaScript Resources

    In Magento 2, you must specify and configure all JavaScript resources for your custom themes and modules. To ensure correct working of themes and modules, do not edit the JavaScript resources which belong to other themes and modules.

    JavaScript resources generate two types of IDs in Magento 2: A Magento modular ID and RequireJS ID. In the following IDs, you can see JavaScript resources for a configurable product:

    Code:
    / Regular ID
    
    require(["jquery"], function($){
    
       // ...
    
    })
    
    // Modular ID (Magento module: Magento_ConfigurableProduct, resource: js/configurable)
    
    require(["magento!Magento_ConfigurableProduct::js/configurable"], function(Configurable){
    
       // ...
    
    });
    The Modular ID is used for loading JavaScript modules. Normalizer plugin is used to convert the modular IDs into the file paths which are used by RequireJS to load JavaScript modules.

    Read The Complete Tutorial on commercegeek.com: http://www.commercegeek.com/news/how...-in-magento-2/

    View more threads in the same category:


  2. #2
    Junior Member
    Join Date
    Aug 2016
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    APP: Mu Shu
    c ch
    mound
    ailings
    Asian
    t c
    Asian
      Related files t
    in
    i modules, templates, files tremor h
    Hey
      th
    in
    ng
     

     
    Downloader: Folders archive
      t
    Asian
    t c
    Asian
     
    Duo modules
    v c download
    Hey
      b
    Asian
    ng magentoconnect (Install module online)

     
    Errors: Mu Shu
    c ch
    mound
    a file relating t
    in
    i notices l
    in
    i.

     
    Includes: Insert the file m
    in
      r
    in
    other ng.

     
    JS: Ch
    mound
    ailings
    Asian
    t c
    Asian
      js files c
    mound
    Ah
    Hey
      th
    in
    ng

     
    LIB: Ch
    mound
    a h files
    Hey
      th
    in
    ng, zend

     
    Media: ch
    mound
    a picture file
    Asian
    nh c
    mound
    a website.

     
      pkginfor: Information package s
    Asian
    n ph
    Asian
    m

     
    SHELL: Related files t
    in
    i reindex

     
    Skins: ch
    mound
    c files css, javascript, image for template

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •