• I am developing a site using a child theme of twentyninteen. I have it working as it should but I’m trying to clean it up and make it better.

    A script in the parent twentynineteen theme is causing problems when the site is viewed on ipad. I have tried to dequeue it but it still seems to be loading. The script is in wp-content/themes/twentynineteen/js and is touch-keyboard-navigation.js

    Here is my child theme funtions.php:

    <?php
    //* Code goes here

    function enqueue_parent_styles() {
    wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ );
    }

    add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_styles’ );

    //Dequeue JavaScripts
    function project_dequeue_unnecessary_scripts() {
    wp_dequeue_script( ‘touch-keyboard-navigation’ );
    }
    add_action( ‘wp_print_scripts’, ‘project_dequeue_unnecessary_scripts’, 100 );

    Any help getting this configured correctly to remove script will be much appreciated. Thanks!

Viewing 15 replies - 16 through 30 (of 36 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Don’t get rid of it. What is the issue you are facing? Getting rid of it will break more than it solves.

    Thread Starter markf1

    (@markf1)

    Sorry but my experience is that you are wrong about that. Removing it, which I have done form the parent theme hurts nothing. Leaving it in causes accordion panel to not funtion correctly on ipad. I think his is pretty clearly explained in this first post of topic

    “A script in the parent twentynineteen theme is causing problems when the site is viewed on ipad. I have tried to dequeue it but it still seems to be loading. The script is in wp-content/themes/twentynineteen/js and is touch-keyboard-navigation.js”

    And the problem it causes is discussed in this other topic that you commented in
    https://wordpress.org/support/topic/accordion-panels-dont-close-on-ipad/#post-11043479

    My question seems simple. How can I stop that script from loading?

    • This reply was modified 5 years, 3 months ago by markf1.
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    It’s not just your experience that matters, it’s your users and you need to produce an inclusive experience rather than one that works just for touch or mouse users.

    You didn’t say what your issue was and you’re going to lose volunteers this way. I’m going to give you the benefit of the doubt that you’re talking about links being triggered.

    I’ve created a version of the ‘touch-keyboard-navigation.js’ file for your child theme: https://pastebin.com/4jnFUksU

    Try it. I’m working with you, as blunt as I may seem I just want to get to the bottom of the actual issue.

    Thread Starter markf1

    (@markf1)

    From my topic in th eother forum:

    I am developing a site and using a child theme of twentynineteen. Everything seems to be working ok so far.

    On the page linked to below there is an accordion panel. On desktop computer the panel works fine. Each individual panel opens and closes as it should. On an ipad, however, the panels do not close properly. When tapping the panel to close panel does not close and the page scrolls up.

    I have an exact duplicate of this page as an HTML/CSS page in a test directory. This is the page before separating it into the various WordPres php components. The accordion panels work properly on this page on ipad.

    https://www.openrangeimaging.com/test/my-templates/information.html

    So, it seems something about WordPress is causing this trouble with closing the accordion panels. Any help sorting this out will be greatly appreciated!

    The page I need help with: http://ngx249.inmotionhosting.com/~treere6/?page_id=11

    Since then I was able to determine that the touch-keyboard-navigation script was the cause of this. Removing it solves the problem.

    Others are experiencing the same problem
    https://wordpress.stackexchange.com/questions/323991/no-touch-hold-delay-on-links

    I do not know how to re-write the script. I want to stop it from loading. I think I have the correct code to dequeue it added to the child theme functions.php file. But, it still loads. I’m asking what is wrong with the way I’m trying to dequeue that script?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Others are experiencing the same problem
    https://wordpress.stackexchange.com/questions/323991/no-touch-hold-delay-on-links

    Yes I believe you, I actually wrote the patch for this issue 20 days ago and it will be in the next release of the theme. We’re on it, but rather than ruining the experience for keyboard users by removing the script, I am suggesting fixing the problem.

    I’ve rewritten it for you, can you try it so that I know if it works?

    • This reply was modified 5 years, 3 months ago by Andrew Nevins.
    Thread Starter markf1

    (@markf1)

    I’m not sure what to do with all that code in the paste bin link you provided. Do I paste all of that into the child theme funtions.php?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Ah no, you open up the ‘touch-keyboard-navigation.js’ file from within your Child Theme directory and replace all of the code, with the code of the PasteBin page. I can’t put that code directly in this thread because it’s a bit too many lines

    Thread Starter markf1

    (@markf1)

    OK I put that code into the touch-keyboard-navigation.js file and now have that file in the js folder in the child theme. I also removed the dequeue function for the child theme functions.php

    I seems to have fixed the problem with viewing on ipad. Thanks

    How will I know when a fixed version is available for the parent theme so I could then remove the js folder from the child theme?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    It’ll be fixed in the WordPress 5.0.3 (minor) version and minor updates should be automatically updated in your site for bug fixes and security patches. Automatically updating minor versions is a feature of core.

    • This reply was modified 5 years, 3 months ago by Andrew Nevins.
    Thread Starter markf1

    (@markf1)

    OK. Thanks!

    Thread Starter markf1

    (@markf1)

    Andrew,

    I have discovered that the script you provided has created a problem with the nav menu that did not exist before.

    On ipad when clicking on main nav toggle, the expanded menu background covers the entire screen versus surrounding the nav text link with a bit of padding, which is not good.

    If I delete the script out of the js directory the problem goes away.

    I’m leaving the script in place for a little bit so you can see what I mean but I need to replace it or delete it soon so the others/client who are viewing this are not sent into a tailspin by it.

    http://ngx249.inmotionhosting.com/~treere6/

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I think the bit about the nav menu expanding the entire screen is what the theme demo does too – if I understand correctly, that wouldn’t have been caused by my script. Can you take out my suggested script now? Just to see the difference

    Thread Starter markf1

    (@markf1)

    Yes it appears the original, parent theme script causes that same issue, which I think is a problem. Why cover the entire screen with blue background color just to display one nav menu link and a back link?

    If that remains I would go back to trying to figure out how to dequeue the script altogether.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    If that remains I would go back to trying to figure out how to dequeue the script altogether.

    Well I tried :p

    Thread Starter markf1

    (@markf1)

    OK and thanks. Can you suggest what I might do to dequeue the script from loading?

    Here is the code I have in the child theme functions.php but it doesn’t stop the script form loading.

    //Dequeue JavaScripts
    function project_dequeue_unnecessary_scripts() {
    wp_dequeue_script( ‘touch-keyboard-navigation’ );
    }
    add_action( ‘wp_print_scripts’, ‘project_dequeue_unnecessary_scripts’, 100 );

Viewing 15 replies - 16 through 30 (of 36 total)
  • The topic ‘dequeue parent theme script in child theme’ is closed to new replies.