# Silly hack to change BabylonJS version on mobile

**URL:** <https://forum.babylonjs.com/t/silly-hack-to-change-babylonjs-version-on-mobile/13596>\
**Category:** Feature requests\
**Tags:** tutorial, playground\
**Created:** [August 22, 2020, 9:14pm UTC](https://forum.babylonjs.com/t/silly-hack-to-change-babylonjs-version-on-mobile/13596 "2020-08-22T21:14:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yondar](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/yondar/32/10552_2.png) [@yondar](https://forum.babylonjs.com/u/yondar)\
**Post date:** [August 22, 2020, 9:14pm UTC](https://forum.babylonjs.com/t/silly-hack-to-change-babylonjs-version-on-mobile/13596/1 "2020-08-22T21:14:39Z")

</div>

I noticed that the button to change the BabylonJS version is not visible on mobile (tested on latest Android and iOS in their default browsers, Chrome and Safari respectively.)

To work around this, I made a JavaScript snippet you can drop into any playground that will allow you to swap your version. It works by manipulating the version dropdown which exists but is not visible.

Obviously, since it exists and simply isn’t visible, it would be fairly easy to update Playground so the version dropdown exists in the mobile interface. I don’t know who has control over the Playground codebase but I kindly ask that you do it 🙂 if I am able to contribute via pull request I sure can try.

Here’s the snippet:

```
// silly hack to switch BabylonJS version on mobile.
setTimeout( () => {
    if( window.innerWidth > 500 ) return;// rough targeting of mobile only
    const versions_available = [
        'Latest',
        '4.1.0',
        '4.0.3',
        '3.3'
    ];

    const desired_version = versions_available[1]; // change this to change the version it switches to!

    var dropdowns = document.getElementsByClassName('command-dropdown');
    console.log(dropdowns);
    for( var i = 0; i < dropdowns.length; i++ ){
        console.log('dropdown ' + i, dropdowns[i].attributes );
        if( dropdowns[i].attributes.getNamedItem('title').value === 'Versions' ){
            // alert('button exists')
            dropdowns[i].click();
        }
    }
    var current_version = document.getElementsByClassName('version-number')[0].innerHTML;
    // alert('current version: ' + current_version);

    var versions = document.getElementsByClassName('command-dropdown-label');
    console.log(versions);
    for( var i = 0; i < versions.length; i++ ){
        console.log('version ' + i, versions[i].attributes );
        if( versions[i].attributes.getNamedItem('title').value === desired_version ){
            if( current_version !== desired_version ){
                // alert('switching to ' + desired_version);
                versions[i].click();
            } else {
                break;
            }
        }
    }

},3000);

```

PS, I’m diving deep into BJS development for my job, so I expect to be around these forums on the regular. I’ve benefited from this forum already and look forward to contributing more. Cheers!

Nick Kramer  
InnovatAR Inc.  
[https://yondar.me](https://yondar.me)

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [August 24, 2020, 9:31am UTC](https://forum.babylonjs.com/t/silly-hack-to-change-babylonjs-version-on-mobile/13596/2 "2020-08-24T09:31:33Z")

</div>

Well, this should work on mobile as well 🙂  
Thanks for the snippet! we’ll make it work on mobile as well.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 24, 2020, 4:55pm UTC](https://forum.babylonjs.com/t/silly-hack-to-change-babylonjs-version-on-mobile/13596/3 "2020-08-24T16:55:57Z")

</div>

It was me actually blocking that feature 🙂

if you want to add it, you need to add a new control in the hamburger menu for it. I thought it was not used enough to develop it but if someone wants to do a PR, please feel free

The code needs to be added here:

> <https://github.com/BabylonJS/Babylon.js/blob/master/Playground/src/components/hamburgerMenu.tsx#L89>

and you need to update that control to be able to work horizontally:

> <https://github.com/BabylonJS/Babylon.js/blob/master/Playground/src/components/commandDropdownComponent.tsx>

---

<div class="post-metadata">

**Author:** ![yondar](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/yondar/32/10552_2.png) [@yondar](https://forum.babylonjs.com/u/yondar)\
**Post date:** [August 27, 2020, 9:54pm UTC](https://forum.babylonjs.com/t/silly-hack-to-change-babylonjs-version-on-mobile/13596/4 "2020-08-27T21:54:43Z")

</div>

I would love to do a PR but I don’t know Typescript. I planned on learning it someday… kinda busy right now though…

---

<div class="post-metadata">

**Author:** ![phil.harlow](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@phil.harlow](https://forum.babylonjs.com/u/phil.harlow)\
**Post date:** [December 13, 2020, 8:31am UTC](https://forum.babylonjs.com/t/silly-hack-to-change-babylonjs-version-on-mobile/13596/5 "2020-12-13T08:31:37Z")

</div>

Thanks for this!

Right now, the playground defaults to 5.0.0-alpha3, breaking the examples I was trying to view. Without the option to change it, you’re stuck.

Using that script above, I made a simple playground sketch that prompts for the version in case this is helpful for anyone!

(requires entering the text from the drop down, ie 4.2.0 or latest)

> **[Babylon.js Playground](https://playground.babylonjs.com/#TZ8B71)**
