First a bit of advise (since the solution is based on it) – always “enqueue” your scripts, don’t just add them in the footer. Read this, for example .
Now the solution for loading scripts on specific template, since this is what you asked for:
function enqueue_themescrits()
{
if ( is_page_template('contact.php') ) { //the file your contact page uses
wp_register_script( 'google_maps', 'http://maps.google.com/maps/api/js?v=3&sensor=false' );
wp_enqueue_script( 'google_maps' );
}
//Your other enqueued scripts
}
add_action( 'wp_enqueue_scripts', 'enqueue_themescrits' );
EDIT: add this to your functions.php
Related Posts:
- What’s the best way to convert a number to a string in JavaScript?
- What is the difference between call and apply?
- Declaring multiple variables in JavaScript
- what is ScriptResource.axd in the page load in web app?
- What does wp-embed.min.js do in WordPress 4.4?
- How to add javascript just before the closing body tag in the footer of WordPress
- How to use Head JS with all enqueued scripts?
- How to add code to just before closing body tag
- How to add JS in footer
- How to combine javascript files without plugins?
- wp_register_script multiple identifiers?
- Move all the JS files to the bottom|footer, the right way
- How to place script in footer?
- Preloader for a WordPress Site
- javascript conflict
- Weird links found in wordpress footer
- Performance vs plugin genrated javascript
- How can I load certain JavaScripts only on blog pages?
- On click load iframe [closed]
- get_header() in backend – but keep JavaScript and CSS files
- Absolutely print script in footer
- How can I integrate yepnope.js with WordPress (and plugins)?
- addEventListener vs onclick
- How do I check if an array includes a value in JavaScript?
- JavaScript document.getElementById().value logs empty value
- What is console.log?
- window.onload vs document.onload
- Fetch: POST JSON data
- JavaScript hide/show element
- Copy array by value
- Compare two dates with JavaScript
- What’s the difference between event.stopPropagation and event.preventDefault?
- ReferenceError: fetch is not defined
- In reactJS, how to copy text to clipboard?
- SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag
- How to import image (.svg, .png ) in a React Component
- How do I embed PHP code in JavaScript?
- Make javascript alert Yes/No Instead of Ok/Cancel
- How to create a dialog with “yes” and “no” options
- Adding images to a Bootstrap Carousel with AJAX
- XMLHttpRequest cannot load XXX No ‘Access-Control-Allow-Origin’ header
- Uncaught TypeError: Cannot read property ‘props’ of null
- How to handle the `onKeyPress` event in ReactJS?
- ES6: Create Strings using Template Literals – Freecodecamp
- Youtube api – stop video
- Uncaught TypeError: Cannot read property ‘msie’ of undefined – jQuery tools
- How do I convert an integer to binary in JavaScript?
- What does window.jQuery and window.$ mean?
- How to change date format in JavaScript
- Convert CSV data into JSON format using Javascript
- Can not solve: Geocode was not successful for the following reason: OVER_QUERY_LIMIT
- How to set Angular 4 background image?
- ReactJS – .JS vs .JSX
- How to convert date to timestamp?
- ReactJS: Maximum update depth exceeded error
- React, Uncaught ReferenceError: ReactDOM is not defined
- How to implement “select all” check box in HTML?
- JQuery get the title of a button
- How to open a URL using PHP?
- Trying to load jquery into tampermonkey script
- Atom JavaScript Autocomplete
- How to format a UTC date as a `YYYY-MM-DD hh:mm:ss` string using NodeJS?
- How to set text color for my d3 chart title?
- Defining a HTML template to append using JQuery
- How do I bind to list of checkbox values with AngularJS?
- Wildcard string comparison in Javascript
- jQuery select option elements by value
- How to change cursor from pointer to finger using jQuery?
- How to get value in an object’s key using a variable referencing that key?
- Button that refreshes the page on click
- jQuery equivalent of body onLoad
- Replace spaces with dashes and make all letters lower-case
- How to make `setInterval` behave more in sync, or how to use `setTimeout` instead?
- Adding Google Translate to a web site
- wp_localize_script with boolean and init
- WordPress loads whole jQuery UI library
- What is the Javascript event for an item being added to the cart in Woocommerce?
- VB.net and WordPress
- Gutenberg passing block attributes to component in ES6/ESNext
- How to add a custom.js file for a child-theme in a swift way?
- WP REST API Post Status Using JavaScript
- var is undefined in a Gutenberg block
- Got a TypeError after update and need to adapt found solution
- How do you filter the list of states when country is selected? [closed]
- Prevent update_checkout from firing mid-typing
- How to move core js files into the footer
- Building a Featured Gallery component for Gutenberg
- Suddenly extra hex string in tags
- Retrieving data about comments and likes
- Including Styles and JS files to work ON my plugin interface
- Linking wp_enqueue can’t find the javascript file (adds “?ver=x.x.x” to the src)
- Gutenberg – useEffect manipulate DOM after block re-renders DOM
- Javascript working on jsfiddle but not wordpress site?
- Drodown list return issue
- Spans in gutenberg
- Get a default customizeAction text for a section using Customizer JS API
- Put dynamic Javascript in header after doing operations
- Adding javascript blocks to a single file and adding it to the header
- custom page url slug needs illegal ?id=1 for javascript
- How can I look at/edit what’s being sent to post.php when I hit the publish/update button?