diff --git a/lib/liquid.rb b/lib/liquid.rb
index 70d26de..d6334ec 100644
--- a/lib/liquid.rb
+++ b/lib/liquid.rb
@@ -73,5 +73,3 @@ require 'liquid/token'
# Load all the tags of the standard library
#
Dir[File.dirname(__FILE__) + '/liquid/tags/*.rb'].each { |f| require f }
-
-require 'liquid/profiler'
diff --git a/lib/liquid/profiler.rb b/lib/liquid/profiler.rb
index f253e2d..67ad6fa 100644
--- a/lib/liquid/profiler.rb
+++ b/lib/liquid/profiler.rb
@@ -1,9 +1,12 @@
+require 'liquid/profiler/hooks'
+
module Liquid
# Profiler enables support for profiling template rendering to help track down performance issues.
#
- # To enable profiling, pass the profile: true option to Liquid::Template.parse. Then, after
- # Liquid::Template#render is called, the template object makes available an instance of this
+ # To enable profiling, first require 'liquid/profiler'.
+ # Then, to profile a parse/render cycle, pass the profile: true option to Liquid::Template.parse.
+ # After Liquid::Template#render is called, the template object makes available an instance of this
# class via the Liquid::Template#profiler method.
#
# template = Liquid::Template.parse(template_content, profile: true)
@@ -70,16 +73,6 @@ module Liquid
end
end
- def self.hooks_loaded
- @hooks_loaded
- end
-
- def self.load_hooks
- return if @hooks_loaded
- require 'liquid/profiler/hooks'
- @hooks_loaded = true
- end
-
def self.profile_token_render(token)
if Profiler.current_profile && token.respond_to?(:render)
Profiler.current_profile.start_token(token)
diff --git a/lib/liquid/template.rb b/lib/liquid/template.rb
index e10d429..a134962 100644
--- a/lib/liquid/template.rb
+++ b/lib/liquid/template.rb
@@ -250,7 +250,7 @@ module Liquid
def with_profiling
if @profiling && !@options[:included]
- raise "Profiler hooks not loaded, call Liquid::Profiler.load_hooks first" unless Profiler.hooks_loaded
+ raise "Profiler not loaded, require 'liquid/profiler' first" unless defined?(Profiler)
@profiler = Profiler.new
@profiler.start
diff --git a/test/test_helper.rb b/test/test_helper.rb
index e56efee..438f075 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -5,6 +5,7 @@ require 'spy/integration'
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
require 'liquid.rb'
+require 'liquid/profiler'
mode = :strict
if env_mode = ENV['LIQUID_PARSER_MODE']
@@ -12,7 +13,6 @@ if env_mode = ENV['LIQUID_PARSER_MODE']
mode = env_mode.to_sym
end
Liquid::Template.error_mode = mode
-Liquid::Profiler.load_hooks
if Minitest.const_defined?('Test')
# We're on Minitest 5+. Nothing to do here.