WordPress.org

Make WordPress Core

Opened 21 months ago

Last modified 21 months ago

#38255 new enhancement

inclusion of javascript script

Reported by: nmoral Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.6.1
Component: Script Loader Keywords: reporter-feedback close
Focuses: Cc:

Description

When I was working on my themes. I tried to include scripts with Javascript src wp but always include scripts with href. I find class.wp-scripts.php always add base url to my src. I think it is not good for two reasons: 1 - it is best to use for local javascript src scripts. 2 - I think it is not good practice to replace data theme because if developer wants src it is not good to add data without informing.

I think both solution can be imagined: 1 - just do not replace the data from themes 2 - allow possibility for developer to choose to add automaticly base_url for javascript.

Change History (1)

#1 @dd32
21 months ago

  • Keywords reporter-feedback close added

Hi @nmoral and welcome to Trac.

I'll be honest - I'm not 100% sure on what you're asking for here.

When I was working on my themes. I tried to include scripts with Javascript src wp but always include scripts with href. I find class.wp-scripts.php always add base url to my src.

This has to be the expected behaviour, since all assets need to be referenced by absolute URL's, can you explain it with a example perhaps?

1 - just do not replace the data from themes

It simply builds a <script> tag based on the data a theme provides, once again, and example of what you get, and what you expect would greatly help

2 - allow possibility for developer to choose to add automaticly base_url for javascript.

The base_url for Javascript is always going to be the sites home_url, there's no really any way around that..

Note: See TracTickets for help on using tickets.