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

Use browscap-php to detect JavaScript supported version #63

Closed
wants to merge 1 commit into from

Conversation

dunxd
Copy link

@dunxd dunxd commented Oct 3, 2023

See #62 for background.

Currently COPS is searching the user agent string to determine which browsers to send to server-side rendering.

A better approach might be to check browser capabilities, which can be done in a couple of ways:
JavaScript client side check
JavaScript run inside a <script nomodule> tag will be ignored by browsers that support ES6 and up.

PHP server side check
The browscap-php package should allow checking the version of JavaScript that is supported by the browser through . Unfortunately I have yet to figure out how to get browscap-php working. I have managed to get it installed via composer, and used its commands to fetch and convert the browsercap.ini file, but stuck at actually writing code that gets the info. The documentation assumes a lot of knowledge I don't have.

This PR is specifically about getting browscap-php to work.

@dunxd
Copy link
Author

dunxd commented Oct 3, 2023

Actually, after going down this rabbit hole for a couple of hours, I don't think the browscap function detect which version of JavaScript are supported by a browser - it just gives true or false if JavaScript is detected at all! And it does it by parsing the User Agent - see https://browscap.org/ua-lookup.

@dunxd dunxd closed this Oct 3, 2023
@dunxd dunxd deleted the browsecap-test branch October 3, 2023 10:51
@mikespub
Copy link
Member

mikespub commented Oct 3, 2023

Thanks for spending the time to investigate this. As far as I can tell, it's mainly intended to replace/enhance the standard PHP get_browser() function, so it wouldn't go into much detail about the WebKit version etc. indeed

@mikespub mikespub added the enhancement New feature or request label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants