Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#35264 closed enhancement (invalid)

wp_enqueue_script does not allow different types

Reported by: mampf's profile mampf Owned by: swissspidy's profile swissspidy
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Script Loader Keywords:
Focuses: Cc:

Description

Dear devs,

I'd like to include a jsonld markup into my blog. I just created a plugin "wp-jsonld" (being reviewed atm).

I am unable to use wp_enqueue_script() and need to use echo instead, because I cannot change the type of the output. wp_enqueue_script() will always assume "text/javascript", where I need to use "application/ld+json".

Other uses (like json+p) might also be of interest.

Best regards,
Ben

Change History (5)

#1 follow-up: @swissspidy
8 years ago

Why do you want to use wp_enqueue_script() for this? AFAIK json-Id data needs to be inline, while wp_enqueue_script() is specifically for external JavaScript.

#2 in reply to: ↑ 1 ; follow-up: @mampf
8 years ago

Replying to swissspidy:

Why do you want to use wp_enqueue_script() for this? AFAIK json-Id data needs to be inline, while wp_enqueue_script() is specifically for external JavaScript.

I'd love to use some kind of caching. You are right, it needs to be inline. Is it even possible to cache an inline script?

Sorry for opening a ticket, I wasn't aware it needed to be inline.

#3 in reply to: ↑ 2 @swissspidy
8 years ago

  • Milestone Awaiting Review deleted
  • Owner set to swissspidy
  • Status changed from new to reviewing

Replying to mampf:

Replying to swissspidy:

Why do you want to use wp_enqueue_script() for this? AFAIK json-Id data needs to be inline, while wp_enqueue_script() is specifically for external JavaScript.

I'd love to use some kind of caching. You are right, it needs to be inline. Is it even possible to cache an inline script?

It's not possible, but since it's just JSON, so you don't really have to worry about client-side caching.

#4 @mampf
8 years ago

Thanks I'm fine with this. You can close it or have a review in your team if you want to discuss it further. I will just use echo then.

#5 @SergeyBiryukov
8 years ago

  • Resolution set to invalid
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.