-2

My target is to use Drupal in China (or any other country that throttles internet access).

In particular Drupal is not China friendly because of its attempt to load some resources from servers which are not allowed, or run extremely slow because of their filter policy.

In most common Drupal cases, googleapis.com and bootstrapcdn.com. As a consequence sites are really slow: the main content is loaded quickly enough, but then (depending on the browser configuration) the screen remains blank until the requests timeout. Which usually is tents of seconds.

I made some research on the topic, but solution are often localized on the specific module or theme. I would like to find a general solution to apply without the need to patch jQuery or bootstrap or whatever every time.

To find a general solution is not easy because many calls are made runtime from Javascript or CSS imports, so, solving the problem from Javascript doesn't seem to be a solution (or not?).

The best solution I thought until now is to edit the hosts file on the server, redirecting to localhost some of the calls, e.g.,

127.0.0.1 fonts.googleapis.com
::1 fonts.googleapis.com

127.0.0.1 maxcdn.bootstrapcdn.com
::1 maxcdn.bootstrapcdn.com
[...]

But doesn't seem to work, I'm still seeing them among the downloaded resources.

enter image description here

Somebody managed to solve this problem for the Drupal CMS?

blackgreen
  • 34,072
  • 23
  • 111
  • 129
Sandor Mezil
  • 390
  • 1
  • 4
  • 16

1 Answers1

0

jquery update has means to serve a local jquery version.

for the font library it depends how the font is added. either by the theme (then you will have to modify your theme's code or hook_library_alter the library - which probably is quiet hard to maintain) or if it comes by another module that usually comes with an option to serve local version. (like fontawesome).

After all, are you trying to change the server side output or have an local browser extension modify it?

Andre Baumeier
  • 211
  • 2
  • 6
  • Yes, I am using jquery_update in fact. I would like it to work on server side, making the result independent from user's browser features. I'm giving a glance to hook_library_alter, it could be helpful. – Sandor Mezil Mar 21 '16 at 23:45