Magento 1: Most Important Things While You Merge Js

Magento has some built-in configurations to merge all css and js files. This is highly helpful since it helps to improve page load speed and thus it improves the overall SEO of our site.

How Can Do Merging of CSS and Js

You can merge your js and css through the admin side. All you need to do is, go to System > Configurations > Developer and set Yes for Merge Javascripts and Merge Css.

Order of Loading Js Files in Magento

But most of the cases, merging js files will break your pages. Most of the cases, it will be your home page and checkout pages. This is because these are the pages in which most of the sites will have more number of javascript depending functionalities. So in order to avoid such headaches, it would be recommended to keep the following points in mind.

  • Always include jQuery first
  • Include jQuery no conflict js file then. You can find that file in js/jquery/jquery_noconflict.js
  • Include prototype.js
  • Your custom scripts

The order by which we need to load those javascript libraries are very important.

Other Important Points To Note

Other than this, some other points which always keep in mind is:

  • Make sure every js file ends with a semi-colon ; . This is important because, if this semi-colon is missing at the end of each file while merging js files into one file by Magento, it will lead to unnecessary errors. In most of the cases, the error message won’t give any hints to the real issue.
  • Your jQuery depending external scripts and/or inline scripts should use jQuery instead of $. This is to avoid conflict between jQuery library and prototype.js library. If you really want to use $ in jQuery scripts, then always try to use this.
jQuery(function($) {
//inside here you can use $ symbol
});

I hope this post will help you out one way or another. Thank you.

Rajeev K Tomy

3,867 thoughts on “Magento 1: Most Important Things While You Merge Js

  1. Pingback: 2starling
  2. All trends of medicament. Comprehensive side effect and adverse reaction information.
    ivermectin 3
    Learn about the side effects, dosages, and interactions. Medscape Drugs & Diseases.

  3. п»їMedicament prescribing information. Learn about the side effects, dosages, and interactions.
    ivermectin lotion price
    Some are medicines that help people when doctors prescribe. Everything what you want to know about pills.

  4. Pingback: cialis- 20 mg
  5. Some are medicines that help people when doctors prescribe. Everything about medicine.
    top rated ed pills
    Comprehensive side effect and adverse reaction information. п»їMedicament prescribing information.

  6. You have somke reaⅼly good posts and I belіeve I would bе a gooⅾ asset. If yoᥙ ever wɑnt too take somе oof
    tһe load off, Ι’d absolutеly love카지노사이트 tⲟ ѡrite sߋme c᧐ntent for your
    blog in exchange for a link Ьack to mіne. Please send me an email іf іnterested. Tһank ʏou!

  7. 1xBet является одной из самых популярных на рынке. https://bet-promokod.ru/ Большой выбор событий из мира спорта и киберспорта, множество открытых линий, самые высокие коэффициенты. Также, БК имеет широкий функционал и немногие дает возможность совершать ставки по уникальным промокодам. Используя промокоды, вы можете получить настоящие деньги, не внося абсолютно никаких средств. Это реально! Узнать актуальный промокод вы можете прямо сейчас, однако использовать его необходимо в соответствии с условиями и инструкциями, которые приведены ниже.

  8. Государь, чей город хорошо укреплен, а народ
    не озлоблен – не подвергнется нападению.
    Но если это все же случится, неприятель вынужден
    будет с позором ретироваться, ибо все в мире меняется с такой скоростью, что едва ли
    кто-нибудь сможет год содержать в праздности войско, осаждая город.

    5 способов вернуть интерес к работе и увлечениям