Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increasing HTML size #177

Open
musen34 opened this issue Mar 25, 2022 · 1 comment
Open

Increasing HTML size #177

musen34 opened this issue Mar 25, 2022 · 1 comment

Comments

@musen34
Copy link

musen34 commented Mar 25, 2022

Hello,

I have 480 currency items and when I use schema-dts its increasing HTML size, how can I set export async like .json-ld file? I can success it with PHP, now I want to use for my NextJS project with this npm package.

<script type="text/javascript"> document.addEventListener("DOMContentLoaded", function() { $("select[name=market]").on('change',function(){ window.location.href = $(this).val(); }); $.getJSON( "/CURRENCY-LIST-PAGE.jsonld", function( data ) { $( "<script/>", { "type": "application/ld+json", "html": JSON.stringify(data) }).appendTo( "head" ); }); }); </script>
@Eyas
Copy link
Collaborator

Eyas commented Mar 25, 2022

This package only provides typings to be able to construct the right JSON as a plain JS object that you can then stringify and serve however you like.

If you're worried about Google Search only, Google does support dynamically inserting JSON-LD in a script just as you described (source). But this might not work for other consumers of the structured data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants