Skip to content

Commit

Permalink
Inline and compress the Javacript code to eliminate extra HTTP request
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebronner committed Aug 23, 2015
1 parent 5d497f0 commit bd6d516
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Http/Middleware/LaravelCaffeineDripMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function handle($request, Closure $next)
}

if (is_string($content) && strpos($content, '_token')) {
$content = str_replace('</body>', '<script src="' . asset('/genealabs/laravel-caffeine/js/laravel-caffeine.js') . '"></script></body>', $content);
$content = str_replace('</body>', "<script>setInterval(function(){var e=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject('Microsoft.XMLHTTP');e.open('GET','/genealabs/laravel-caffeine/drip',!0),e.send()},5e3);</script></body>", $content);
$response->setContent($content);
}

Expand Down
4 changes: 1 addition & 3 deletions src/LaravelCaffeineServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public function boot()
if (! $this->app->routesAreCached()) {
require __DIR__ . '/Http/routes.php';
}

$this->publishes([__DIR__ . '/public' => public_path('genealabs/laravel-caffeine')], 'genealabs-laravel-caffeine');
}

public function register()
Expand All @@ -25,6 +23,6 @@ public function register()
*/
public function provides()
{
return ['laravel-caffein'];
return ['laravel-caffeine'];
}
}
9 changes: 0 additions & 9 deletions src/public/js/laravel-caffeine.js

This file was deleted.

0 comments on commit bd6d516

Please sign in to comment.