Skip to content

Add plugin options to load scripts on main or worker thread #6

@pradeep910

Description

@pradeep910

Issue

Some scripts have dependencies on other scripts. So if core script is not loaded for example jquery, then it causes Javascript error and breaks functionality.

Possible solutions to try

One way would be to check scripts dependencies We can check the scripts with $deps argument and load those dependencies normally with type="text/javascript".

wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer);

However, there will be some scripts which don't define dependencies, there will be JS error in this case.

The other way is to provide options on backend to allow users to skip or include JS files. Something like an input field with comma separated script names like wp-autoptimize plugin does.

Screenshot 2021-11-12 at 1 24 50 PM

The comma separated JS file names, can be added to $skip_js variable here - https://github.com/rtCamp/rt-scripts-optimizer/blob/main/rt-scripts-optimizer.php#L80-L85

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions