Greeting WP Devs,

I am planning to transfer the script libraries in my function.php . In my function.php I registered AOS

function mypage() {
  if ( is_page( 'mypage' ) ) {

wp_register_script( 'aosjs', get_template_directory_uri() . 'js/aos.js', array( 'jquery' ), NULL, false );    
   wp_enqueue_script( 'aosjs' );

   wp_enqueue_script( 'jquery.min' );

add_action( 'wp_enqueue_scripts', 'testingarea');

Page Name : mypage

https://mysite/mypage/ - My script has cdn with AOS.init

 <script src="js/aos.js"></script>
    easing: 'ease-in-out-sine'

First Test- AOS is registered in functions.php aand in mypage I removed the cdn in the mypage Page and aos init is still there but the result is

enter image description here


PLease kindly give me suggestions on how to declare this properly.


The function get_template_directory_uri() returns the path without trailing slash.
So you need to write

wp_register_script( 'aosjs', get_template_directory_uri() . '/js/aos.js',...)

Note the slash before "js/aos.js".
What good for is this line, the script file should already be loaded:

<script src="js/aos.js"></script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.