Can Google crawl dynamic structured data added in a window.onload() event?Rich Snippet/Structured Data Testing Tool errorsStructured Data Tool doesn't see JavaScript rendered contentIs JSON-LD supported by Google?Google isn't surfacing Events rich snippets in SERP when JSON-LD Structured Data is validJSON-LD detected by the structured data validation tool, but not by the search consoleJSON-LD script is showing on Google Structured Data Testing tool and page source but not in Mobile Friendly TestGoogle SDTT does not fetch structured data by URL

Job offer without any details but asking me to withdraw other applications - is it normal?

Can I conceal an antihero's insanity - and should I?

My research paper filed as a patent in China by my Chinese supervisor without me as inventor

Integer Decision Variables Always Forced to Zero in Minimization Problem (MINLP)

"Literally" Vs "In the true sense of the word"

Selecting 2 column in an Inner join

Why isn't `typename` required for a base class that is a nested type?

Resume: How to quantify my contributions as a software engineer?

Leaving out pronouns in informal conversation

What's the biggest organic molecule that could have a smell?

Does a gnoll speak both Gnoll and Abyssal, or is Gnoll a dialect of Abyssal?

In Germany, how can I maximize the impact of my charitable donations?

The Planck constant for mathematicians

Does an oscilloscope subtract voltages as phasors?

Gravity on an Orbital Ring

How can I fix a framing mistake so I can drywall?

I asked for a graduate student position from a professor. He replied "welcome". What does that mean?

Sol Ⅲ = Earth: What is the origin of this planetary naming scheme?

What exactly is a marshrutka (маршрутка)?

How can I locate a missing person abroad?

Where to disclose a zero day vulnerability

Where can I find vomiting people?

How is Team Scooby Doo (Mystery Inc.) funded?

How seriously should I take a CBP interview where I was told I have a red flag and could only stay for 30 days?



Can Google crawl dynamic structured data added in a window.onload() event?


Rich Snippet/Structured Data Testing Tool errorsStructured Data Tool doesn't see JavaScript rendered contentIs JSON-LD supported by Google?Google isn't surfacing Events rich snippets in SERP when JSON-LD Structured Data is validJSON-LD detected by the structured data validation tool, but not by the search consoleJSON-LD script is showing on Google Structured Data Testing tool and page source but not in Mobile Friendly TestGoogle SDTT does not fetch structured data by URL






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I inject some JSON-LD into a page dynamically via Javascript, when I test the page using Google's Structured Data Testing Tool, the expected output appears and I can see the Product Element is rendered.



However, if I defer loading of the script that is responsible for fetching the JSON-LD content and then call the function to inject it in a window "load" event listener, the content no longer appears in the Structured Data Testing Tool.



In short the testing tool shows my markup when I do this...



<script src="https://example.site.com/rich-snippet/dist.js"></script>
<script>
richSnippet();
</script>


But not when I do this.



<script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
<script>
window.addEventListener('load', (event) =>
richSnippet();
);
</script>


I guess I'm asking whether this is a shortcoming in the Testing Tool or whether the defer / onload approach is a step too far in terms of Google being able to index the content.










share|improve this question









New contributor



Luke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Why would you add this markup via JavaScript at all? Seems like having it in the HTML code would be the most straightforward way and most likely to get picked up by search engines.

    – Stephen Ostermiller
    10 hours ago











  • Because it is fetched via an API to include latest product review data (live total, aggregate rating and review content) this can't really be static HTML as would require updating more than hourly with latest data. Could fetch data server side on page load but that would require much more implementation and not be site agnostic. :)

    – Luke
    10 hours ago

















3















I inject some JSON-LD into a page dynamically via Javascript, when I test the page using Google's Structured Data Testing Tool, the expected output appears and I can see the Product Element is rendered.



However, if I defer loading of the script that is responsible for fetching the JSON-LD content and then call the function to inject it in a window "load" event listener, the content no longer appears in the Structured Data Testing Tool.



In short the testing tool shows my markup when I do this...



<script src="https://example.site.com/rich-snippet/dist.js"></script>
<script>
richSnippet();
</script>


But not when I do this.



<script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
<script>
window.addEventListener('load', (event) =>
richSnippet();
);
</script>


I guess I'm asking whether this is a shortcoming in the Testing Tool or whether the defer / onload approach is a step too far in terms of Google being able to index the content.










share|improve this question









New contributor



Luke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Why would you add this markup via JavaScript at all? Seems like having it in the HTML code would be the most straightforward way and most likely to get picked up by search engines.

    – Stephen Ostermiller
    10 hours ago











  • Because it is fetched via an API to include latest product review data (live total, aggregate rating and review content) this can't really be static HTML as would require updating more than hourly with latest data. Could fetch data server side on page load but that would require much more implementation and not be site agnostic. :)

    – Luke
    10 hours ago













3












3








3








I inject some JSON-LD into a page dynamically via Javascript, when I test the page using Google's Structured Data Testing Tool, the expected output appears and I can see the Product Element is rendered.



However, if I defer loading of the script that is responsible for fetching the JSON-LD content and then call the function to inject it in a window "load" event listener, the content no longer appears in the Structured Data Testing Tool.



In short the testing tool shows my markup when I do this...



<script src="https://example.site.com/rich-snippet/dist.js"></script>
<script>
richSnippet();
</script>


But not when I do this.



<script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
<script>
window.addEventListener('load', (event) =>
richSnippet();
);
</script>


I guess I'm asking whether this is a shortcoming in the Testing Tool or whether the defer / onload approach is a step too far in terms of Google being able to index the content.










share|improve this question









New contributor



Luke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I inject some JSON-LD into a page dynamically via Javascript, when I test the page using Google's Structured Data Testing Tool, the expected output appears and I can see the Product Element is rendered.



However, if I defer loading of the script that is responsible for fetching the JSON-LD content and then call the function to inject it in a window "load" event listener, the content no longer appears in the Structured Data Testing Tool.



In short the testing tool shows my markup when I do this...



<script src="https://example.site.com/rich-snippet/dist.js"></script>
<script>
richSnippet();
</script>


But not when I do this.



<script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
<script>
window.addEventListener('load', (event) =>
richSnippet();
);
</script>


I guess I'm asking whether this is a shortcoming in the Testing Tool or whether the defer / onload approach is a step too far in terms of Google being able to index the content.







googlebot javascript json-ld google-rich-snippets-tool






share|improve this question









New contributor



Luke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



Luke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 1 hour ago









unor

19.6k3 gold badges33 silver badges91 bronze badges




19.6k3 gold badges33 silver badges91 bronze badges






New contributor



Luke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 10 hours ago









LukeLuke

1184 bronze badges




1184 bronze badges




New contributor



Luke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Luke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

















  • Why would you add this markup via JavaScript at all? Seems like having it in the HTML code would be the most straightforward way and most likely to get picked up by search engines.

    – Stephen Ostermiller
    10 hours ago











  • Because it is fetched via an API to include latest product review data (live total, aggregate rating and review content) this can't really be static HTML as would require updating more than hourly with latest data. Could fetch data server side on page load but that would require much more implementation and not be site agnostic. :)

    – Luke
    10 hours ago

















  • Why would you add this markup via JavaScript at all? Seems like having it in the HTML code would be the most straightforward way and most likely to get picked up by search engines.

    – Stephen Ostermiller
    10 hours ago











  • Because it is fetched via an API to include latest product review data (live total, aggregate rating and review content) this can't really be static HTML as would require updating more than hourly with latest data. Could fetch data server side on page load but that would require much more implementation and not be site agnostic. :)

    – Luke
    10 hours ago
















Why would you add this markup via JavaScript at all? Seems like having it in the HTML code would be the most straightforward way and most likely to get picked up by search engines.

– Stephen Ostermiller
10 hours ago





Why would you add this markup via JavaScript at all? Seems like having it in the HTML code would be the most straightforward way and most likely to get picked up by search engines.

– Stephen Ostermiller
10 hours ago













Because it is fetched via an API to include latest product review data (live total, aggregate rating and review content) this can't really be static HTML as would require updating more than hourly with latest data. Could fetch data server side on page load but that would require much more implementation and not be site agnostic. :)

– Luke
10 hours ago





Because it is fetched via an API to include latest product review data (live total, aggregate rating and review content) this can't really be static HTML as would require updating more than hourly with latest data. Could fetch data server side on page load but that would require much more implementation and not be site agnostic. :)

– Luke
10 hours ago










1 Answer
1






active

oldest

votes


















4
















<script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
<script>
window.addEventListener('load', function()
richSnippet();
);
</script>


Removing the ES6 syntax seems to resolve the issue, I think due the context of the event that would be passed.




Stephen Ostermiller:




Why would you add this markup via JavaScript at all? Seems like having it in the >HTML code would be the most straightforward way and most likely to get picked up by search engines.




Why would you not use JavaScript or any other language? Having the hardcoded HTML is counter intuitive in every case that comes to mind.






share|improve this answer










New contributor



breakworm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "45"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );







    Luke is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwebmasters.stackexchange.com%2fquestions%2f125103%2fcan-google-crawl-dynamic-structured-data-added-in-a-window-onload-event%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4
















    <script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
    <script>
    window.addEventListener('load', function()
    richSnippet();
    );
    </script>


    Removing the ES6 syntax seems to resolve the issue, I think due the context of the event that would be passed.




    Stephen Ostermiller:




    Why would you add this markup via JavaScript at all? Seems like having it in the >HTML code would be the most straightforward way and most likely to get picked up by search engines.




    Why would you not use JavaScript or any other language? Having the hardcoded HTML is counter intuitive in every case that comes to mind.






    share|improve this answer










    New contributor



    breakworm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      4
















      <script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
      <script>
      window.addEventListener('load', function()
      richSnippet();
      );
      </script>


      Removing the ES6 syntax seems to resolve the issue, I think due the context of the event that would be passed.




      Stephen Ostermiller:




      Why would you add this markup via JavaScript at all? Seems like having it in the >HTML code would be the most straightforward way and most likely to get picked up by search engines.




      Why would you not use JavaScript or any other language? Having the hardcoded HTML is counter intuitive in every case that comes to mind.






      share|improve this answer










      New contributor



      breakworm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        4














        4










        4









        <script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
        <script>
        window.addEventListener('load', function()
        richSnippet();
        );
        </script>


        Removing the ES6 syntax seems to resolve the issue, I think due the context of the event that would be passed.




        Stephen Ostermiller:




        Why would you add this markup via JavaScript at all? Seems like having it in the >HTML code would be the most straightforward way and most likely to get picked up by search engines.




        Why would you not use JavaScript or any other language? Having the hardcoded HTML is counter intuitive in every case that comes to mind.






        share|improve this answer










        New contributor



        breakworm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        <script src="https://example.site.com/rich-snippet/dist.js" defer=""></script>
        <script>
        window.addEventListener('load', function()
        richSnippet();
        );
        </script>


        Removing the ES6 syntax seems to resolve the issue, I think due the context of the event that would be passed.




        Stephen Ostermiller:




        Why would you add this markup via JavaScript at all? Seems like having it in the >HTML code would be the most straightforward way and most likely to get picked up by search engines.




        Why would you not use JavaScript or any other language? Having the hardcoded HTML is counter intuitive in every case that comes to mind.







        share|improve this answer










        New contributor



        breakworm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share|improve this answer



        share|improve this answer








        edited 1 hour ago









        unor

        19.6k3 gold badges33 silver badges91 bronze badges




        19.6k3 gold badges33 silver badges91 bronze badges






        New contributor



        breakworm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        answered 8 hours ago









        breakwormbreakworm

        562 bronze badges




        562 bronze badges




        New contributor



        breakworm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




        New contributor




        breakworm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.


























            Luke is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded

















            Luke is a new contributor. Be nice, and check out our Code of Conduct.












            Luke is a new contributor. Be nice, and check out our Code of Conduct.











            Luke is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Webmasters Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwebmasters.stackexchange.com%2fquestions%2f125103%2fcan-google-crawl-dynamic-structured-data-added-in-a-window-onload-event%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

            The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу