Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6614469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:20:35+00:00 2026-05-25T20:20:35+00:00

If I have this line in my view: <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js></script> Do I also put

  • 0

If I have this line in my view:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

Do I also put my actual script in my view?

 <script type="text/javascript">                                         
 $(document).ready(function() {

     alert("Hello world!");

 }); </script>

Or do I put my actual javascript somewhere else and send it to the view somehow?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:20:35+00:00Added an answer on May 25, 2026 at 8:20 pm

    This is how i do it. For page specific javascript i include it in the page itself. For other javascript that would need to be run on most pages i put it in the global javascript, mine is called main.js.

    So, as an example, say you would like to hide some_div on page load, and this div is on a specific page.

    <body> 
       <div id="content"> 
        <div id="some_div">
    
        </div> 
       </div> 
    </body> 
    

    Then you would just do that in the page specific javascript.

    An example of the main/global javscript file would be js that you want run on each page. So some examples are fadeIn animations for the content area, if all/most your pages have a content area and you would like to fade the content in on every page load, then the global java script would be a good place to put it so you don’t have repeated code. Another example is if you want to make all inputs with a class="calendar" into a datepicker, then in your global js file you would just do.

    $(function(){ 
        $('.calendar').datepicker()
    });
    

    This way you don’t have to do that for each page and have repeated code. Long story short, if you are going to use the same js code in other pages too then might as well put it in a global js file.


    In relation to codeigniter. What i did was create a “view partial” (really just a view) for all my js and css files. So in my view js.php i have:

      <script type="text/javascript" src="/javascript/jquery.js" /> </script> 
      <script type="text/javascript" src="/javascript/jquery-ui.js" /> </script> 
      <script type="text/javascript" src="/javascript/main.js" /> </script>   
    

    Then i just reference this view partial in the view page that i need to include the scripts i.e

    <?php $this->load->view('/common/js') ?>
    

    This way i don’t need to manually include the javascript files i need for each view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have this line of code in the view. <?php echo CHtml::activeTextField($model,'start_time'); ?>
I want to draw this in my view to draw this line, I have
I have this line samtools view -h file | awk '$3==chr$a || /^@/' |
I have this line in the declarations section: Private filePath As String And something
I have this line in my program : InputStream Resource_InputStream=this.getClass().getClassLoader().getResourceAsStream(Resource_Name); But how can I
I have this line below that shows a link to go the next page
I have this line of code: this.Path = pathLookUpLocation.GetValue(RegLookupKey, null).ToString(); When I run static
I have this line of code: System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shinfo.hIcon); A few lines later,
If I have this line and I'm wondering if there's better way to do
For example we have this line chart at Google Code API there is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.