0

Hy guys! On my site I noticed that on some pages I don't have a Jquery library included. But on other pages I see it in my head tag:

    <head>
        ...
        <script type="text/javascript" src="/assets/fe9bd624/jquery.js"></script>
        <script type="text/javascript" src="/assets/fe9bd624/jquery.ba-bbq.js"></script>
        ...
    </head>

In my theme layout/main.php I don't have Jquery files in head tag. So question is: what controls inserting Jquery on my pages, and how to insert it on all pages. Thx.

1
  • I've inserted next line in my layout file: <?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>. So now Jquery works on all pages. But where I can find a list of pages on which Jquery inserts automatically? Commented Apr 12, 2012 at 6:06

3 Answers 3

5

jQuery would only be inserted automatically if you call the registerCoreScript method. There's nothing built into Yii to force jQuery upon you.

However, it could be that your using a widget or extension somewhere that uses jQuery, which would make it's own call to the registerCoreScript. (CGridView for example)

Sign up to request clarification or add additional context in comments.

1 Comment

One more thing that I noticed, the jquery will be auto inserted above the <title> tag in head section, so you can add the CSS above it and rest of your jquery dependent js below it.
0

If you use any widget or component or extension which needs jquery & using function registerCoreScript than jquery will be loaded automatically otherwise YII does not load any JQuery.

Comments

0

In every view that requires jquery you can put this on top:

<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>

You can put it into your layout also if you want to include in all pages in a particular layout.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.