I have a multi-lingual website. For each page, in the HTML header, I set the language variations as follows:
<link rel="alternate" href="https://www.example.com/a-page/" hreflang="en"/>
<link rel="alternate" href="https://www.example.com/fr/a-page/" hreflang="fr"/>
<link rel="alternate" href="https://www.example.com/pt/a-page/" hreflang="pt"/>
<link rel="alternate" href="https://www.example.com/ca/a-page/" hreflang="ca"/>
<link rel="alternate" href="https://www.example.com/sc/a-page/" hreflang="sc"/>
<link rel="alternate" href="https://www.example.com/it/a-page/" hreflang="it"/>
<link rel="alternate" href="https://www.example.com/es/a-page/" hreflang="es"/>
<link rel="alternate" href="https://www.example.com/ro/a-page/" hreflang="ro"/>
<link rel="alternate" href="https://www.example.com/an/a-page/" hreflang="an"/>
<link rel="alternate" href="https://www.example.com/oc/a-page/" hreflang="oc"/>
<link rel="alternate" href="https://www.example.com/eo/a-page/" hreflang="eo"/>
<link rel="alternate" href="https://www.example.com/gl/a-page/" hreflang="gl"/>
<link rel="alternate" href="https://www.example.com/a-page/" hreflang="x-default"/>
But the thing is, that takes up at least 25% of some of my pages.
I'm considering reducing the above HTML code to a javascript version that I put at the bottom of the page so people located in an area (example: middle of a country road) with poor internet service (and with a browser that can't handle gzipped pages) can access my pages quickly without waiting for the language declarations to be processed.
How would search engines react if I put my language declarations as javascript code? Will they still try to show the multilingual versions, or will they ignore them completely and pray through page crawling that such multilingual versions exist?