jqueryyiieditorwmdprettify

Yii`s jQuery.yii.js not loading first


i am using wmd editor which,it has its own js files that requires jQuery to be be loaded first,however Yii framework has its own Jquery library that is registered in the asset that loads after all head elements,Wmd editor crushes if jQuery is not loaded first so i had to include it first of all head elements,when the page loads,the jQuery.yii is also added at the end of all head elements,in short,it gets loaded twice and creates conflicts in my code,here is my file looks like in head

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="en" />
    <script type="text/javascript" src="/codepac/css/wmd/showdown.js"></script>
   <b> <script type="text/javascript" src="/codepac/css/wmd/jQuery/jquery-1.2.6.min.js "></script></b>
    <script type="text/javascript" src="/codepac/css/custom_js.js "></script>
    <script type="text/javascript" src="/codepac/css/prettify/src/prettify.js"></script>

In the browser i can locate another copy of Jquery loaded automatically at the end of all head elements like this

<script type="text/javascript" src="/codepacu/assets/21a12630/jquery.js"></script>

I was wondering if there is a way which i could load it first,or not load it at all and use google`s cdn copy.

thanks


Solution

  • @Grampa's answer will only help with loading from Google, but won't help with your WMD issues.

    Looks like WMD is using a very old version of jQuery (1.2.6), while Yii uses 1.7.1. You're going to run into all kinds of conflicts, and there aren't any great workarounds for this.

    There's this answer about including multiple versions of jQuery on a page, but you have to change one of them to be referenced as $$ instead of $. That means you'd probably have to either go through and change all the jQuery objects in WMD to use $$ instead of $, which is non-trivial at best, and a nightmare if WMD ever updates.

    If I were you, I'd look for a more modern WYSIWYG editor that uses a modern version of jQuery that's compatible with 1.7.1 , and try to integrate it instead.